#!coding=utf-8

from django.db import models

class Collect(models.Model):
    """
    收税类型表
    """
    name = models.CharField(max_length=20)
    pos = models.IntegerField()

    def __unicode__(self):
        return self.name

class Region(models.Model):
    """
    分区表
    """
    name = models.CharField(max_length=20)
    code = models.CharField(max_length=5)
    pos = models.IntegerField()

    def __unicode__(self):
        return "%s - %s " % (self.name, self.code)

class Department(models.Model):
    """
    税务部门表
    """
    name = models.CharField(max_length=20)
    pos = models.IntegerField()

    def __unicode__(self):
        return self.name

class Enterprise(models.Model):
    """
    企业表
    """
    name = models.CharField(max_length=100)
    code = models.CharField(max_length=15)
    collect = models.ForeignKey('Collect')
    Department = models.ForeignKey('Department')
    modify = models.DateTimeField(auto_now=True)

    

    def __unicode__(self):
        return "%s - %s - %s " % (self.name, self.code, self.modify)

class Assert(models.Model):
    """
    房地产信息表
    """
    KIND_CHOICES = (
        ('FC',u'房产'),
        ('DC',u'地产'),
        )
    
    region = models.ForeignKey('Region')
    enterprise = models.ForeignKey('Enterprise')
    area = models.DecimalField(max_digits=20, decimal_places=2)
    address = models.CharField(max_length=200)
    evaluation = models.DecimalField(max_digits=20, decimal_places=2)
    price = models.DecimalField(max_digits=20, decimal_places=2)
    kind = models.CharField(max_length=2,choices=KIND_CHOICES)
    modify = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return "%s - %s - %s" % (self.enterprise.name, self.address, self.kind)
    

class Case(models.Model):
    """
    受理业务表
    """
    STATUS_CHOICES = (
        ('DJ',u'登记完成'),
        ('SH',u'审核完成'),
        ('NS',u'已纳税完成'),
        ('QB',u'全部完成'),
        )
    
    create = models.DateTimeField(auto_now_add=True)
    name = models.CharField(max_length=50)
    code = models.CharField(max_length=18)
    money = models.DecimalField(max_digits=20, decimal_places=2)
    proportion = models.DecimalField(max_digits=5, decimal_places=2)
    investDate = models.DateField()
    phone = models.CharField(max_length=15)
    status = models.CharField(max_length=2,choices=STATUS_CHOICES)
    enterprise = models.ForeignKey('Enterprise')
    department = models.ForeignKey('Department')
    modify = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return "%s - %s - %s " % (self.enterprise.name, self.name, self.create)
    
class CaseTax(models.Model):
    """
    应纳税信息表
    """
    case = models.ForeignKey('Case')

    address = models.CharField(max_length=100)

    incometax = models.DecimalField(max_digits=20, decimal_places=2)
    stamptax = models.DecimalField(max_digits=20, decimal_places=2)
    othertax = models.DecimalField(max_digits=20, decimal_places=2)
    alltax = models.DecimalField(max_digits=20, decimal_places=2)

    modify = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return "%s - %s " % (self.case, self.modify)
    
class CompleteTax(models.Model):
    """
    应纳税信息表
    """
    case = models.ForeignKey('Case')

    incometax = models.DecimalField(max_digits=20, decimal_places=2)
    stamptax = models.DecimalField(max_digits=20, decimal_places=2)
    othertax = models.DecimalField(max_digits=20, decimal_places=2)
    alltax = models.DecimalField(max_digits=20, decimal_places=2)

    paytime = models.DateTimeField(auto_now_add=True)

    modify = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return "%s - %s " % (self.case, self.modify)

class Check(models.Model):
    """
    查账征收表
    """
    case = models.ForeignKey('Case')
    f1 = models.DecimalField(max_digits=20, decimal_places=2)
    f11 = models.DecimalField(max_digits=20, decimal_places=2)
    f12 = models.DecimalField(max_digits=20, decimal_places=2)
    f2 = models.DecimalField(max_digits=20, decimal_places=2)
    f21 = models.DecimalField(max_digits=20, decimal_places=2)
    f22 = models.DecimalField(max_digits=20, decimal_places=2)
    f221 = models.DecimalField(max_digits=20, decimal_places=2)
    f222 = models.DecimalField(max_digits=20, decimal_places=2)
    f23 = models.DecimalField(max_digits=20, decimal_places=2)
    f231 = models.DecimalField(max_digits=20, decimal_places=2)
    f232 = models.DecimalField(max_digits=20, decimal_places=2)    
    f3 = models.DecimalField(max_digits=20, decimal_places=2)
    f31 = models.DecimalField(max_digits=20, decimal_places=2)
    f32 = models.DecimalField(max_digits=20, decimal_places=2)
    f33 = models.DecimalField(max_digits=20, decimal_places=2)
    f34 = models.DecimalField(max_digits=20, decimal_places=2)
    f35 = models.DecimalField(max_digits=20, decimal_places=2)
    f4 = models.DecimalField(max_digits=20, decimal_places=2)
    f5 = models.DecimalField(max_digits=20, decimal_places=2)
    f6 = models.DecimalField(max_digits=20, decimal_places=2)
    modify = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return "%s - %s " % (self.case, self.modify)

class Verify(models.Model):
    """
    查账征收表
    """
    case = models.ForeignKey('Case')
    f1 = models.DecimalField(max_digits=20, decimal_places=2)
    f11 = models.DecimalField(max_digits=20, decimal_places=2)
    f12 = models.DecimalField(max_digits=20, decimal_places=2)
    f2 = models.DecimalField(max_digits=20, decimal_places=2)
    f21 = models.DecimalField(max_digits=20, decimal_places=2)    
    f211 = models.DecimalField(max_digits=20, decimal_places=2)
    f212 = models.DecimalField(max_digits=20, decimal_places=2)
    f22 = models.DecimalField(max_digits=20, decimal_places=2)        
    f221 = models.DecimalField(max_digits=20, decimal_places=2)
    f222 = models.DecimalField(max_digits=20, decimal_places=2)
    f23 = models.DecimalField(max_digits=20, decimal_places=2)
    f3 = models.DecimalField(max_digits=20, decimal_places=2)        
    f31 = models.DecimalField(max_digits=20, decimal_places=2)
    f32 = models.DecimalField(max_digits=20, decimal_places=2)
    f33 = models.IntegerField()
    f34 = models.DecimalField(max_digits=20, decimal_places=2)
    f4 = models.DecimalField(max_digits=20, decimal_places=2)
    f41 = models.DecimalField(max_digits=20, decimal_places=2)
    f42 = models.DecimalField(max_digits=20, decimal_places=2)
    f43 = models.DecimalField(max_digits=20, decimal_places=2)
    f44 = models.DecimalField(max_digits=20, decimal_places=2)    
    f5 = models.DecimalField(max_digits=20, decimal_places=2)
    f6 = models.DecimalField(max_digits=20, decimal_places=2)
    f7 = models.DecimalField(max_digits=20, decimal_places=2)    
    modify = models.DateTimeField(auto_now=True)

    def __unicode__(self):
        return "%s - %s " % (self.case, self.modify)

